package com.zhw.controller;

import com.zhw.pojo.PageBean;
import com.zhw.pojo.RecordDTO;
import com.zhw.pojo.Result;
import com.zhw.service.RecordService;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
public class RecordController {

    @Autowired
    RecordService recordService;



    @PostMapping("borrow")
    public Result borrowing(String isbn){
      log.info("借阅书本信息：{}",isbn);
      recordService.borrow(isbn);
      return Result.success();
    }

    public Result newMethod4(String isbn){
      log.info("借阅书本信息：{}",isbn);
      recordService.borrow(isbn);
      return Result.success();
    }





    @GetMapping("getRecord")
    public Result page(RecordDTO recordDTO){
        log.info("借阅记录分页查询信息：{}",recordDTO);
        PageBean pb=recordService.page(recordDTO);
        return Result.success(pb);
    }


    @PutMapping("give")
    public Result give(String isbn){
        log.info("书本归还：{}",isbn);
        recordService.give(isbn);
        return Result.success();
    }



}
